testmodelbutton: Add explanatory comments to CSS
authorDaniel Boles <dboles.src@gmail.com>
Sun, 8 Apr 2018 15:07:35 +0000 (16:07 +0100)
committerDaniel Boles <dboles.src@gmail.com>
Sun, 8 Apr 2018 17:48:16 +0000 (18:48 +0100)
and load at an earlier, more sensible place, before creating any widgets

tests/testmodelbutton.c

index c32b5aa87a5d9b71b5634b7272887e2fa13f593f..c7268e48c32593c75ab1ab27dc83f7cea4ae858a 100644 (file)
@@ -22,6 +22,21 @@ on_application_activate (GApplication *gapplication,
   GtkWidget *model_button;
   GtkWidget *widget;
 
+  gtk_css_provider_load_from_data (css_provider,
+    "window > box { padding: 0.5em; }"
+    "window > box > * { margin: 0.5em; }"
+    /* :iconic == FALSE */
+    "modelbutton > check { background: red; }"
+    "modelbutton > radio { background: green; }"
+    "modelbutton > arrow { background: blue; }"
+    /* :iconic == TRUE */
+    "button.model { background: yellow; }"
+    , -1);
+  g_assert (GDK_IS_DISPLAY (display));
+  gtk_style_context_add_provider_for_display (display,
+                                              GTK_STYLE_PROVIDER (css_provider),
+                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
   action = g_simple_action_new ("beep", NULL);
   g_signal_connect (action, "activate", G_CALLBACK (on_action_beep), NULL);
   g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
@@ -54,19 +69,6 @@ on_application_activate (GApplication *gapplication,
   gtk_container_add (GTK_CONTAINER (box), widget);
 
   widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_css_provider_load_from_data (css_provider,
-    "window > box { padding: 0.5em; }"
-    "window > box > * { margin: 0.5em; }"
-    "modelbutton > check { background: red; }"
-    "modelbutton > radio { background: green; }"
-    "modelbutton > arrow { background: blue; }"
-    "button.model { background: yellow; }"
-    , -1);
-  g_assert (GDK_IS_DISPLAY (display));
-  gtk_style_context_add_provider_for_display (display,
-                                              GTK_STYLE_PROVIDER (css_provider),
-                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
   gtk_container_add (GTK_CONTAINER (widget), box);
   gtk_widget_show (widget);
   gtk_application_add_window (GTK_APPLICATION (application), GTK_WINDOW (widget));